util = {}
sleep_time = 1000
-- 获取屏幕大小
w,h = getScreenSize()
function clickAndSleep(arr,delay)
    for i,v in ipairs(arr) do
        if(v[3]) then delay = v[3]  elseif delay then else delay = sleep_time end
        tap(v[1],v[2],100)
        mSleep(delay)
    end
end

function findImgAndClick(src)
    -- 全屏找图片
    local x,y = findImage(src,0,0,w-1,h-1);
    clickAndSleep({{x,y}})
    return x,y
end

function moveAndFind(src)
    -- 先滑动至最左侧
    screenMove(807,862,-500)
    local x,y = findImgAndClick(src);
    if (x~=-1) then
        return
    end
    -- 慢慢滑动至右侧
    for i=1,10 do
        screenMove(1184,862,i*5)
        local x,y = findImgAndClick(src);
        if (x~=-1) then
            return
        end
    end
end

function screenMove(x,y,offset)
    touchDown(x,y)
    mSleep(30)
    touchMove(x-offset,y)
    mSleep(30)
    touchUp(x-offset,y)
end

function useSkill(arr,delay)
    for i,v in ipairs(arr) do
        if(v[3]) then delay = v[3]  elseif delay then else delay = sleep_time end
        tap(v[1],v[2],100)
        -- 普工一下
        touchDown(1427,731)
        -- 按住移动
        touchDown(2,375,686)
        mSleep(delay)
    end
end
return util